package com.example.demo.dao;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.example.demo.entity.User;

@Mapper
public interface UserDao {
	@Results(id="UserResultsMap",
			value={
			@Result(property = "id", column = "user_id"), 
			@Result(property = "name", column = "u_name"),
			@Result(property = "age", column = "u_age")
	})
	@Select("select * from `test-mybatis`.t_user")
	List<User> findAll();
	

	@ResultMap("UserResultsMap")
	@Select("select * from `test-mybatis`.t_user where user.u_age=#{age}")
	User findByAge(@Param("age") int age);
}
